import qs from "qs";
import http from "@/api";
import { SelectExperimentaPageType, QueryParamType, addEditFormDataType, editPwsType } from "./type";

// 使用枚举包含所有的Path
enum Api {
  // 查询实验员列表
  selectExperimentalistList = "/tbLabUser/selectByPage",
  // 删除实验员
  delLabUser = "/tbLabUser/delete",
  // 修改实验员
  editLabUser = "/tbLabUser/edit",
  // 添加实验员
  addLabUser = "/tbLabUser/add",
  // 重置密码
  resetPsw = "/tbLabUser/resetPsw",
  // 修改密码
  editPsw = "/tbLabUser/editPsw",
  // 查询实验员下的实验室
  selectUserLab = "/tbLabUser/selectUserLab"
}

// 查询实验员的Api
export const selectExperimentalistListApi = (data: QueryParamType) => {
  let dataQ = "?" + qs.stringify(data);
  return http.post<SelectExperimentaPageType>(Api.selectExperimentalistList + dataQ, {}, { loading: false });
};

// 添加实验员的Api
export const addLabUserApi = (data: addEditFormDataType) => {
  let dataQ = "?" + qs.stringify(data);
  return http.post(Api.addLabUser + dataQ, {}, { loading: false });
};

// 修改实验员的Api
export const editLabUserApi = (data: addEditFormDataType) => {
  let dataQ = "?" + qs.stringify(data);
  return http.post(Api.editLabUser + dataQ, {}, { loading: false });
};

// 删除实验员的Api
export const delLabUserApi = (data: { tbLabUserId: number | null | undefined | string }) => {
  let dataQ = "?" + qs.stringify(data);
  return http.post(Api.delLabUser + dataQ, {}, { loading: false });
};

// 重置密码的Api
export const resetPswApi = (data: { tbLabUserId: number | null | undefined | string }) => {
  let dataQ = "?" + qs.stringify(data);
  return http.post(Api.resetPsw + dataQ, {}, { loading: false });
};

// 修改密码的Api
export const editPswApi = (data: editPwsType) => {
  let dataQ = "?" + qs.stringify(data);
  return http.post(Api.editPsw + dataQ, {}, { loading: false });
};

// 查询实验员下的实验室列表的Api
export const selectUserLabApi = (data: { selectUserId: number | string | null | undefined }) => {
  let dataQ = "?" + qs.stringify(data);
  return http.post(Api.selectUserLab + dataQ);
};
